<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
<script type="text/javascript" th:src="@{/js/jquery.js}"></script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>采购管理</li>
    <li>商品类型管理</li>
    <li>添加</li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>商品类型信息</span></div>
  <form action="/erp/purchase/ctype/doadd" method="post" id="tform">
  <ul class="forminfo">
    <li >
      <span style="font-weight: bold;color:red;" th:text="${msg}"></span>
    </li>
    <li>
      <label>品牌名称</label>
      <select class="dfselect" name="brandId">
        <option value="0">请选择</option>
        <option th:each="cb :${cbrands}" th:value="${cb.brandId}" th:text="${cb.brandName}">联想</option>
      </select>
      <i>必选</i>
    </li>
    <li>
      <label>商品类型名称</label>
      <input name="typeName" type="text" class="dfinput" />
      <i>必填，不能超过50个字符</i>
    </li>
    <li>
      <label>状态</label>
      <select class="dfselect" name="typeStatus">
          <option value="1">可用</option>
          <option value="2">不可用</option>
        </select>
      <i>必选</i>
    </li>
    <li>
      <label>创建人</label>
      <input type="hidden" name="createId" th:value="${session.users.UId}">
      <input name="" type="text" th:value="${session.users.uname}" readonly="readonly" class="roinput" />
      <i>不能编辑</i>
    </li>
    <li>
      <label>创建时间</label>
      <input name="createTime" type="text" value="" readonly="readonly" class="roinput" />
      <i>不能编辑</i>
    </li>
    <li>
      <label>&nbsp;</label>
      <input name="" type="button" onclick="submit1()" class="btn" value="确定"/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name="" type="button" class="btn" value="返回" onclick="window.location.href='/erp/purchase/ctype/ctlist'"/>
    </li>
  </ul>
  </form>
</div>
<script>
  var date = new Date();
  var seperator = "-";
  var year = date.getFullYear();
  var month = date.getMonth() + 1;
  var strDate = date.getDate();
  if (month >= 1 && month <= 9) {
    month = "0" + month;
  }
  if (strDate >= 0 && strDate <= 9) {
    strDate = "0" + strDate;
  }
  var currentDate = year + seperator + month + seperator + strDate; //当前日期
  $("input[name=createTime]").val(currentDate);

  function bidnonull() {
    var val = $("select[name=brandId]").val();
    if(val!=0){
      return true;
    }else{
      alert("请选择品牌！");
      return false;
    }
  }

  function tnamenonull() {
    var val = $("input[name=typeName]").val();
    if(val!="" && val!=null){
      return true;
    }else{
      alert("请输入商品类型名称！");
      return false;
    }
  }

  function submit1() {
    if(bidnonull() && tnamenonull()){
      $("#tform").submit();
    }
  }
</script>
</body>
</html>
